import React from 'react';
// eslint-disable-next-line import/no-named-default
import { default as CM } from '@/components/ComboModal';

// setValidationLocale({
//   zh: {
//     required: '这是定制必填文案',
//     custom_format: '必须是数字  <% injectVar %>',
//   },
// });

// registerValidationRules({
//   customRule: value => {
//     return value === '123' ? '不能等于123' : '';
//   },
// });

/**
 *
 * 自定义组件ComboModal 挂载在FormItem时,editable会被FormItem 自动转义成readOnly传给ComboModal
 */
function ComboModal({
  mode,
  disabled = false,
  readOnly = false,
  placeholder = '请选择',
  modalProps,
  tableProps,
  onChange,
  value,
}) {
  return (
    <CM
      value={Array.isArray(value) ? value : []}
      placeholder={placeholder}
      disabled={disabled}
      readOnly={mode === 'readOnly' || readOnly === true}
      modalProps={{
        destroyPopupOnHide: true,
        ...modalProps,
        onOk: selectedRows => {
          onChange(selectedRows);
        },
      }}
      tableProps={{
        url: '',
        searchPlaceholder: '输入关键字',
        rowKey: 'id',
        label: 'name',
        columns: [],
        multiple: false,
        filterScope: '',
        ...tableProps,
      }}
    />
  );
}

ComboModal.defaultProps = {};

ComboModal.propTypes = {};

export default ComboModal;
